/*
 * Copyright 2004 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jbfilter.hibernate.factory;

import org.jbfilter.hibernate.FilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.logic.AndFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.logic.DynamicLogicFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.logic.OrFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.logic.XorFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.multiple.StartEndDateFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.single.ComparableFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.single.ContainsStringFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.single.DateFilterComponentHibernate;
import org.jbfilter.hibernate.fcomps.single.EqualsFilterComponentHibernate;
import org.jbfilter.impl.FilterComponentHibernatesProviderImpl;

/**
 * This class is a factory for creating {@link FilterComponentHibernate}'s.
 * <p/>
 * <i>Following explanations are only relevant to implementers:</i>
 * <p/>
 * You may switch the implementation provider by using {@link #setProvider(FilterComponentHibernatesProvider)}.
 * An instance of the default provider is always accessible by {@link #newDefaultProvider()}. This comes in handy if you
 * want use some but not all implementations from the default implementation.
 * 
 * @author Marcus Adrian
 */

public class FilterComponentHibernates {
	private static FilterComponentHibernatesProvider PROVIDER = newDefaultProvider();
	
	public static void setProvider(FilterComponentHibernatesProvider p) {
		PROVIDER = p;
	}
	public static FilterComponentHibernatesProvider getProvider() {
		return PROVIDER;
	}
	public static FilterComponentHibernatesProvider newDefaultProvider() {
		return new FilterComponentHibernatesProviderImpl();
	}
	// EqualsFilterComponent
	public static <E, T> EqualsFilterComponentHibernate<E, T> newEqualsFilterComponent() {
		return PROVIDER.<E, T>newEqualsFilterComponent();
	}
	public static <E, T> EqualsFilterComponentHibernate<E, T> newEqualsFilterComponent(String id) {
		return PROVIDER.<E, T>newEqualsFilterComponent(id);
	}
	public static <E, T> EqualsFilterComponentHibernate<E, T> newEqualsFilterComponent(String id, String propertyPath) {
		return PROVIDER.<E, T>newEqualsFilterComponent(id, propertyPath);
	}
	
	// ContainsStringFilterComponent
	public static <E> ContainsStringFilterComponentHibernate<E> newContainsStringFilterComponent() {
		return PROVIDER.<E>newContainsStringFilterComponent();
	}
	public static <E> ContainsStringFilterComponentHibernate<E> newContainsStringFilterComponent(String id) {
		return PROVIDER.<E>newContainsStringFilterComponent(id);
	}
	public static <E> ContainsStringFilterComponentHibernate<E> newContainsStringFilterComponent(String id, String propertyPath) {
		return PROVIDER.<E>newContainsStringFilterComponent(id, propertyPath);
	}
	
	// DateFilterComponent
	public static <E> DateFilterComponentHibernate<E> newDateFilterComponent() {
		return PROVIDER.<E>newDateFilterComponent();
	}
	public static <E> DateFilterComponentHibernate<E> newDateFilterComponent(String id) {
		return PROVIDER.<E>newDateFilterComponent(id);
	}
	public static <E> DateFilterComponentHibernate<E> newDateFilterComponent(String id, String propertyPath) {
		return PROVIDER.<E>newDateFilterComponent(id, propertyPath);
	}
	
	// StartEndDateFilterComponent
	public static <E> StartEndDateFilterComponentHibernate<E> newStartEndDateFilterComponent() {
		return PROVIDER.<E>newStartEndDateFilterComponent();
	}
	public static <E> StartEndDateFilterComponentHibernate<E> newStartEndDateFilterComponent(String id) {
		return PROVIDER.<E>newStartEndDateFilterComponent(id);
	}
	public static <E> StartEndDateFilterComponentHibernate<E> newStartEndDateFilterComponent(String id, String propertyPath) {
		return PROVIDER.<E>newStartEndDateFilterComponent(id, propertyPath);
	}

	// ComparableFilterComponent
	public static <E, T extends Comparable<? super T>> ComparableFilterComponentHibernate<E, T> newComparableFilterComponent() {
		return PROVIDER.<E, T>newComparableFilterComponent();
	}
	public static <E, T extends Comparable<? super T>> ComparableFilterComponentHibernate<E, T> newComparableFilterComponent(String id) {
		return PROVIDER.<E, T>newComparableFilterComponent(id);
	}
	public static <E, T extends Comparable<? super T>> ComparableFilterComponentHibernate<E, T> newComparableFilterComponent(String id, String propertyPath) {
		return PROVIDER.<E, T>newComparableFilterComponent(id, propertyPath);
	}
	
	// AndFilterComponent
	public static <E> AndFilterComponentHibernate<E> newAndFilterComponent() {
		return PROVIDER.<E>newAndFilterComponent();
	}
	public static <E> AndFilterComponentHibernate<E> newAndFilterComponent(String id) {
		return PROVIDER.<E>newAndFilterComponent(id);
	}

	// OrFilterComponent
	public static <E> OrFilterComponentHibernate<E> newOrFilterComponent() {
		return PROVIDER.<E>newOrFilterComponent();
	}
	
	public static <E> OrFilterComponentHibernate<E> newOrFilterComponent(String id) {
		return PROVIDER.<E>newOrFilterComponent(id);
	}

	// XorFilterComponent
	public static <E> XorFilterComponentHibernate<E> newXorFilterComponent() {
		return PROVIDER.<E>newXorFilterComponent();
	}
	public static <E> XorFilterComponentHibernate<E> newXorFilterComponent(String id) {
		return PROVIDER.<E>newXorFilterComponent(id);
	}

	// DynamicLogicFilterComponent
	public static <E> DynamicLogicFilterComponentHibernate<E> newDynamicLogicFilterComponent() {
		return PROVIDER.<E>newDynamicLogicFilterComponent();
	}

	public static <E> DynamicLogicFilterComponentHibernate<E> newDynamicLogicFilterComponent(String id) {
		return PROVIDER.<E>newDynamicLogicFilterComponent(id);
	}


}